<?php
session_start();
include_once("../../untils/conn.php");
mysqli_query($con, "set names utf8");

// 获取当前正在登录的账号信息的代理
$proxy_acc = $_SESSION["account"];

// 查询proxy表，找到符合条件的数据并输出给前端
$sql = "SELECT * FROM proxy WHERE proxy_acc = '$proxy_acc'";
$result = mysqli_query($con, $sql);
if ($result) {
    $rows = mysqli_fetch_assoc($result);
    $id = $rows["proxy_id"];

    $sql = "SELECT * FROM proxy WHERE proxy_upid = '$id'";
    $result = mysqli_query($con, $sql);
    if ($result && mysqli_num_rows($result) > 0) {
        $data = array();
        while ($row = mysqli_fetch_assoc($result)) {
            $proxy_accs = $row['proxy_acc'];
            $proxy_phone = $row['proxy_phone'];
            $proxy_rename = $row['proxy_rename'];
            $proxy_rename_sta = $row['proxy_rename_sta'];
            $proxy_sta = $row['proxy_sta'];
            $proxy_balance = $row['proxy_balance'];

            // 将代理名和代理头像添加到数据数组中
            $data[] = array(
                "account" => $proxy_accs,
                "phone" => $proxy_phone,
                "rename" => $proxy_rename,
                "rename_sta" => $proxy_rename_sta,
                "status" => $proxy_sta,
                "puid" => $proxy_acc,
                "balance" => $proxy_balance,
            );
        }
        echo json_encode($data);
    } else {
        echo json_encode(array("error" => "没有符合条件的数据"));
    }
} else {
    echo json_encode(array("error" => "查询出错"));
}
?>
